using Enter.Admin.Utils;
using Microsoft.AspNetCore.Mvc.Rendering;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Enter.Admin.Enums
{
    public class EnumsExt
    {
        public static ConcurrentDictionary<string, List<SelectListItem>> EnumMap;
        static EnumsExt()
        {
            EnumMap = GetEnumMap();
        }
        public static ConcurrentDictionary<string, List<SelectListItem>> GetEnumMap()
        {
            var result = new ConcurrentDictionary<string, List<SelectListItem>>();
            var enums = Assembly.GetExecutingAssembly().GetTypes().Where(t=>t.Namespace == "Enter.Admin.Enums" && t.IsEnum);
            foreach (var item in enums)
            {
                result.TryAdd(item.Name, Tools.EnumList(item));
            }
            return result;
        }
    }
}